<?php
/* 
 * based on: http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Require the base controller
/*
 * JPATH_CONTROLLER = base component path, also JPATH_COMPONENT_SITE and JPATH_COMPONENT_ADMINISTRATOR are defined
 * DS = directory separator
 */


require_once( JPATH_COMPONENT.DS.'controller.php' );


// Require specific controller if requested (in case multiple controllers are defined)
if($controller = JRequest::getWord('controller')) { //JRequest:getWord() finds a word variable in the URL or the POST data.
    $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
    if (file_exists($path)) {
        require_once $path;
    } else {
        $controller = '';  //empty for the default controller
    }
}

// Create the controller
$classname    = 'Controller'.$controller;
$controller   = new $classname( );

// Perform the Request task
$controller->execute( JRequest::getWord( 'task' ) );

// Redirect if set by the controller
$controller->redirect();


//don't use a closing php tag in php-only files (common practice to avoid wite-spaces in the output code